/**
 * Copyright 2012 Alfredo "Rainbowbreeze" Morresi
 * 
 * This file is part of Eureka! project.
 * 
 * Eureka! is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * Eureka! is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with Eureka!. If not, see http://www.gnu.org/licenses/.
 */
package it.rainbowbreeze.eureka.data;

import it.rainbowbreeze.eureka.common.AppEnv;
import it.rainbowbreeze.eureka.common.ResultOperation;
import it.rainbowbreeze.eureka.domain.QualityDataPoint;
import it.rainbowbreeze.eureka.util.TestHelper;
import android.content.Context;
import android.test.AndroidTestCase;

/**
 * @author Alfredo "Rainbowbreeze" Morresi
 *
 */
public class WebserviceManagerTest extends AndroidTestCase {
    // ------------------------------------------ Private Fields
    private WebserviceManager mWebserviceManager;

    // -------------------------------------------- Constructors

    // -------------------------------------- Setup and TearDown
    @Override
    protected void setUp() throws Exception {
        super.setUp();

        Context context = getContext();
        assertNotNull("Context is null", context);
        TestHelper.init(context);
        mWebserviceManager = AppEnv.i(getContext()).getWebserviceManager();
    }

    // --------------------------------------------------- Tests
    public void testGetDataPoints_emptyZone() {
        ResultOperation<QualityDataPoint[]> result = mWebserviceManager.getDataPoints(
                -90000000,
                -18000000,
                1000,
                new int[] {4});
        assertNotNull("Is null", result);
        assertFalse("Has errors", result.hasErrors());
        assertNull("Is not null", result.getResult());
    }

    public void testGetDataPoints() {
        ResultOperation<QualityDataPoint[]> result = mWebserviceManager.getDataPoints(
                42000000,
                12000000,
                100000,
                new int[] {4});
        assertNotNull("Is null", result);
        assertFalse("Has errors", result.hasErrors());
        assertNotNull("Is null", result.getResult());
        QualityDataPoint[] data = result.getResult();
        assertTrue("No data returned", data.length > 0);
    }

    // ----------------------------------------- Private Methods

    // ----------------------------------------- Private Classes
}
